package com.juice.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.juice.model.Book;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * @desc:
 * @author: panxiyi
 * @date: 2023/4/12 12:48 下午
 */

//@SpringBootTest
public class BookServiceTestCase {

    @Autowired
    private IBookService bookService;

    @Test
    public void getByIdTest() {
        Book book = bookService.getById(1L);
        System.out.println(book);
    }


    @Test
    public void saveTest() {
        Book book = new Book(7L, "音乐", "二胡---", "好听的很");
        bookService.save(book);
    }

    @Test
    public void getByPage() {
        //IPage<Book> page = bookService.getByPage(3, 2);
        IPage<Book> page = new Page<Book>(3, 2);
        bookService.page(page);
        page.getRecords().forEach(System.out::println);
    }

    @Test
    public void updateTest() {
        Book book = new Book();
        book.setId(6L);
        book.setDescription("羌笛何须怨杨柳中的笛子");
        bookService.updateById(book);
    }

    @Test
    public void getALl() {
        System.out.println(bookService.list());
    }
}
